const { defineConfig } = require('@vue/cli-service');
const CompressionPlugin = require('compression-webpack-plugin');
const path = require('path');
const productionGzipExtensions = ['js', 'css'];
module.exports = defineConfig({
  transpileDependencies: true,
  outputDir: 'ELement pro',
  assetsDir: "static",
  productionSourceMap: false,
  chainWebpack: config => {
    config.resolve.alias.set('@', path.resolve(__dirname, './src'))
    .set('@I', path.resolve(__dirname, './src/assets/img'));
  },
  configureWebpack: config => {

    // 开启Gzip压缩
    // if (isProduction) {
    config.plugins.push(
      new CompressionPlugin({
        algorithm: 'gzip',
        test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
        threshold: 500,
        minRatio: 0.8
      })
    );
  }
});
